package com.comum.javahomework420242025.pojo;

import com.comum.javahomework420242025.utils.LocalDateTimeDeserializer;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;


@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name = "trace")
public class Trace {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "chanceid", length = 255)
    private Long chanceid;

    @Column(name = "visitor", length = 255)
    private String visitor;

    @Column(name = "visittime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 指定 JSON 输出的格式
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime visittime;

    @Column(name = "thing")
    private String thing;

    @Column(name = "situation")
    private String situation;

    @Column(name = "comment")
    private String comment;

    @Column(name = "userid", length = 255)
    private Long userid;

    @ManyToOne
    @JoinColumn(name = "chanceid", insertable = false, updatable = false)
    private Chance chance;

    @ManyToOne
    @JoinColumn(name = "userid", insertable = false, updatable = false)
    private User user;
}